;(async () => {
    const options = {
        moduleCache: {vue: Vue},
        async getFile(url) {
            const res = await fetch(url);
            if (!res.ok){
                throw Object.assign(new Error(url + ' ' + res.statusText), { res });
            }                
            const content = await res.text();
            // if (/.*?\.jsx$/.test(url)) {
            //     return { content: content, type: ".mjs" };
            // }
            return content;
        },
        addStyle(textContent) {
            document.head.insertBefore(
                Object.assign(document.createElement('style'), {textContent}),
                document.head.getElementsByTagName('style')[0] || null);
        },
    };
    const {loadModule} = window['vue3-sfc-loader'];

    const loadVue = (vuePath) => loadModule(vuePath, options);
    const loadVueFile = (vuePath) => () => loadVue(vuePath);

    let routes = [
        /*首页*/
        {path: '/', component: loadVueFile('./views/index.vue')},
    ]

    const args = {name: 'app', components: {'layout': await loadVue('./views/layout.vue')}};

    const app = Vue.createApp(args)
    app.use(VueRouter.createRouter({history: VueRouter.createWebHashHistory(), routes: routes}))
    app.mount("#app")

})().catch(ex => console.error(ex));
